package com.example.testdemo.image_progress_bar;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.testdemo.R;

/**
 * Created by 颜 on 04.12.012.
 * 图片进度条
 * 两张图片组合成一个进度条样式
 * 一张背景图，一张前景图
 */

public class ImageProgressBarActivity extends Activity {
    private ImageProgressBar imageProgressBar;
    private TextView progressText;
    private int progress = 0;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_progress_bar);
        initView();
    }

    private void initView() {
        imageProgressBar = findViewById(R.id.progressBar);
        progressText = findViewById(R.id.progressText);

        imageProgressBar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (progress > 100){
                    progress = 0;
                }
                progress = progress + 1;
                imageProgressBar.setProgress(progress);
                progressText.setText("当前进度：" + progress);
            }
        });
    }
}
